const path = require("path");

function addStyleResource(rule) {
  rule
    .use("style-resource")
    .loader("style-resources-loader")
    .options({
      patterns: [path.resolve(__dirname, "./src/assets/css/global.less")],
    });
}
module.exports = {
  publicPath: "/",
  outputDir: "imageMonitor", //构建时输出的目录
  assetsDir: "staic", //放置静态资源目录
  indexPath: "index.html", //html 输出路径
  filenameHashing: true, //文件名哈希值
  productionSourceMap: false,
  pages: {
    index: {
      entry: "src/main.js", //page 入口文件
      template: "public/index.html", //模板文件
      filename: "index.html", //在dist/index.html 的输出文件
      title: "电力巡检",
    },
  },

  chainWebpack(config) {
    const types = ["vue-modules", "vue", "normal-modules", "normal"];
    types.forEach((type) =>
      addStyleResource(config.module.rule("less").oneOf(type))
    );
  },
  // module: {
  //   rule: {
  //     test: /\.less$/,
  //     use: ["vue-style-loader", "css-loader", "less-loader"],
  //   },
  // },
  configureWebpack: {},
  // pluginOptions: {
  //   "style-resources-loader": {
  //     preProcessor: "less",
  //     patterns: ["./src/assets/css/global.less"],
  //   },
  // },
  devServer: {
    host: "0.0.0.0",
    port: 8053,
    open: true,
    proxy: {
      "/platform": {
        target: "http://117.160.141.22:6015",
        changeOrigin: true,
        logLevel: "debug",
        // pathRewrite: {
        //   "^/platform": "/",
        // },
      },
      "/qimg": {
        target: "http://192.168.15.33:8036",
        changeOrigin: true,
        pathRewrite: {
          "^/qimg": "/",
        },
      },
      "/apiz": {
        target: "http://192.168.15.33:6030",
        changeOrigin: true,
        pathRewrite: {
          "^/apiz": "/",
        },
      },
      "/login": {
        target: "http://117.160.141.22:6015/",
        changeOrigin: true,
        // pathRewrite: {
        //   "^/platform": "/",
        // },
      },
    },
  },
};
